#!/sbin/openrc-run

extra_started_commands="reload"
run_dir="/var/run/radiusd"
command="/usr/sbin/radiusd"
command_args="$RADIUSD_OPTS"
pidfile="$run_dir/radiusd.pid"
name="Freeradius"
conf="/etc/raddb/radiusd.conf"
user="$(grep -v '#' $conf | grep 'user =' | awk -F " = " '{ print $2 }')"
group="$(grep -v '#' $conf |grep 'group =' | awk -F " = " '{ print $2 }')"

depend() {
	need net
	after firewall
	use dns
}

start_pre() {
	checkpath --directory --owner ${user}:${group} --mode 0775 ${run_dir}
}

reload () {
	ebegin "Reloading $name"
	kill -HUP `cat $pidfile`
	eend $?
}
